﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">

    <ControlTemplate x:Key="RibbonControlTemplate"
                     TargetType="{x:Type Fluent:Ribbon}">
        <Grid x:Name="PART_LayoutRoot"
              Width="Auto"
              Height="Auto">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <!-- When you change the default height of 25 of the RibbonTitleBar to something else, don't forget to change it in code behind (see OnIsCollapsedChanged) -->
            <Fluent:RibbonTitleBar x:Name="PART_RibbonTitleBar"
                                   Height="25"
                                   Style="{DynamicResource RibbonTitleBarStyle}"
                                   Margin="20,0,113,0"
                                   VerticalAlignment="Top"
                                   IsCollapsed="{TemplateBinding IsCollapsed}">
                <Fluent:RibbonTitleBar.Header>
                    <Grid>
                        <Rectangle x:Name="rectangle"
                                   Fill="#7FFFFFFF"
                                   Stroke="{x:Null}"
                                   StrokeThickness="0"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Width="{Binding ActualWidth, ElementName=PART_Title, Mode=Default}"
                                   Height="{Binding ActualHeight, ElementName=PART_Title, Mode=Default}"
                                   RadiusX="2"
                                   RadiusY="2">
                            <Rectangle.Effect>
                                <BlurEffect Radius="10" />
                            </Rectangle.Effect>
                        </Rectangle>
                        <TextBlock x:Name="PART_Title"
                                   Padding="4,0,4,0"
                                   VerticalAlignment="Center"
                                   d:LayoutOverrides="Width"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=Title,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
                                   Foreground="Black"
                                   TextWrapping="NoWrap"
                                   TextTrimming="CharacterEllipsis" />
                    </Grid>
                </Fluent:RibbonTitleBar.Header>
            </Fluent:RibbonTitleBar>

            <Fluent:RibbonTabControl Menu="{TemplateBinding Menu}"
                                     Style="{DynamicResource RibbonTabControlStyle}"
                                     x:Name="PART_RibbonTabControl"
                                     Margin="0,25,0,0"
                                     Focusable="False"
                                     ContextMenu="{Binding ContextMenu, ElementName=PART_LayoutRoot}" />
            <!--<ContentPresenter x:Name="button" Margin="2,26,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                          ContentSource="Menu"/>-->
            <Border x:Name="border"
                    Margin="0,-2,0,0"
                    BorderBrush="{DynamicResource QuickAccessToolBarOutterBorderBrush}"
                    BorderThickness="0,1"
                    Grid.Row="1"
                    Height="26">
                <Border BorderBrush="{DynamicResource QuickAccessToolBarInnerBorderBrush}"
                        BorderThickness="0,1"
                        Background="{DynamicResource QuickAccessToolBarInnerBackgroundBrush}">
                    <ContentControl x:Name="contentControl"
                                    HorizontalAlignment="Left">
                        <Fluent:QuickAccessToolBar x:Name="PART_QuickAccessToolBar"
                                                   Style="{DynamicResource QuickAccessToolbarStyle}"
                                                   ShowAboveRibbon="{Binding ShowQuickAccessToolBarAboveRibbon, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                   HorizontalAlignment="Left"
                                                   Focusable="False" />
                    </ContentControl>
                </Border>
            </Border>           
        </Grid>
        <ControlTemplate.Triggers>
            <!--<Trigger Property="CanQuickAccessLocationChanging" Value="False">
        <Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarBelowTheRibbonMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarAboveTheRibbonMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="separator" Value="Collapsed"/>
      </Trigger>-->
            <Trigger Property="IsQuickAccessToolBarVisible"
                     Value="False">
                <Setter Property="Visibility"
                        TargetName="border"
                        Value="Collapsed" />
                <Setter Property="Visibility"
                        TargetName="PART_QuickAccessToolBar"
                        Value="Collapsed" />
                <!--<Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarBelowTheRibbonMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarAboveTheRibbonMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_RemoveFromQuickAccessMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_AddGalleryToQuickAccessMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_AddMenuToQuickAccessMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_AddGroupToQuickAccessMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="PART_AddToQuickAccessMenuItem" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="separator" Value="Collapsed"/>
        <Setter Property="Visibility" TargetName="topMenuSeparator" Value="Collapsed"/>-->
            </Trigger>
            <Trigger Property="IsCollapsed"
                     Value="True">
                <Setter Property="Visibility"
                        TargetName="PART_RibbonTabControl"
                        Value="Collapsed" />
                <Setter Property="Visibility"
                        TargetName="border"
                        Value="Collapsed" />               
            </Trigger>
            <Trigger Property="ShowQuickAccessToolBarAboveRibbon"
                     Value="True">
                <Setter Property="Content"
                        TargetName="contentControl"
                        Value="{x:Null}" />
                <Setter Property="QuickAccessToolBar"
                        TargetName="PART_RibbonTitleBar"
                        Value="{Binding ElementName=PART_QuickAccessToolBar, Mode=OneWay}" />
                <Setter Property="Visibility"
                        TargetName="border"
                        Value="Collapsed" />
                <Setter Property="Margin"
                        TargetName="PART_QuickAccessToolBar"
                        Value="0,2,0,0" />
            </Trigger>
            <!--<MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="Visibility" Value="Collapsed" SourceName="PART_AddToQuickAccessMenuItem"/>
          <Condition Property="Visibility" Value="Collapsed" SourceName="PART_AddGroupToQuickAccessMenuItem"/>
          <Condition Property="Visibility" Value="Collapsed" SourceName="PART_AddMenuToQuickAccessMenuItem"/>
          <Condition Property="Visibility" Value="Collapsed" SourceName="PART_AddGalleryToQuickAccessMenuItem"/>
          <Condition Property="Visibility" Value="Collapsed" SourceName="PART_RemoveFromQuickAccessMenuItem"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" Value="Collapsed" TargetName="topMenuSeparator"/>
      </MultiTrigger>-->
            <!--<Trigger Property="ShowQuickAccessToolBarAboveRibbon" Value="True">
        <Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarAboveTheRibbonMenuItem" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="ShowQuickAccessToolBarAboveRibbon" Value="False">
        <Setter Property="Visibility" TargetName="PART_ShowQuickAccessToolbarBelowTheRibbonMenuItem" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="CanCustomizeQuickAccessToolBar" Value="False">
        <Setter Property="Visibility" TargetName="PART_CustomizeQuickAccessToolbarMenuItem" Value="Collapsed"/>
      </Trigger>
      <Trigger Property="CanCustomizeRibbon" Value="False">
        <Setter Property="Visibility" TargetName="PART_CustomizeTheRibbonMenuItem" Value="Collapsed"/>
      </Trigger>-->
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RibbonStyle"
           TargetType="{x:Type Fluent:Ribbon}">
        <Setter Property="Foreground"
                Value="{DynamicResource DefaultFontBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource DefaultFontFamily}" />
        <Setter Property="FontSize"
                Value="{DynamicResource DefaultFontSize}" />
        <Setter Property="Template"
                Value="{StaticResource RibbonControlTemplate}" />
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource ControlStyleEmptyFocus}" />
        <Setter Property="FocusManager.IsFocusScope"
                Value="False" />
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="Fluent:FrameworkHelper.UseLayoutRounding"
                Value="True" />
    </Style>
</ResourceDictionary>